﻿#ifndef _tcp_server_20220407_
#define _tcp_server_20220407_

#include <thread>
#include <map>
#include <list>
#include <mutex>
#include "SL_asynFramePub.h"

#include "SLT_tool_pub_def.h"
#include "SL_tcpClient.h"
class SLTcpServerCB
{
public:
	virtual void TcpServer_onConnect(SLTcpClientPtr& _client) = 0;
	virtual void TcpServer_onError() = 0;
};
class SLTcpServer
{
public:
	virtual ~SLTcpServer() {}
	virtual int  init(SLTcpServerCB* pcb) = 0;
	virtual void uninit() = 0;
	virtual void start() = 0;
	virtual void stop() = 0;
	//addListen：ip为空表示任意地址，_port为0表示任意端口，同时作为出参返回
	//返回值小于0表示失败，大于0表示成功监听的端口号
	virtual int addListen(std::string _ip, int &_port) = 0;
    virtual int delListen(std::string _ip, int _port) = 0;

	virtual SLTcpClientPtr   createClient() = 0;
};
typedef std::shared_ptr<SLTcpServer> SLTcpServerStpr;

SLT_API SLTcpServerStpr sl_createTcpServer();


#endif